package cn.sciento.farm.devicemanager.gateway.downlink;

import cn.sciento.farm.devicemanager.common.util.SpringContextHolder;
import cn.sciento.farm.devicemanager.gateway.downlink.service.impl.MqttSendService;
import cn.sciento.farm.devicemanager.gateway.model.downlink.MqttContent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.TimerTask;

/**
 * User: wumu
 * Date: 1/17/18
 * Time: 6:08 PM
 */
public class MqttTaskFactory {
    private Logger logger = LoggerFactory.getLogger(MqttTaskFactory.class);

    private static MqttSendService mqttSendService = SpringContextHolder.getBean(MqttSendService.class);

    public static TimerTask sendDefault(MqttContent mqttContent) {
        return new TimerTask() {
            @Override
            public void run() {
                mqttSendService.send(mqttContent);
            }
        };
    }
}
